<?php

session_start();

if (isset($_REQUEST['loginout'])){
	session_destroy();
}

if($_SESSION['name']){
	header('Location: index.php');
	die;
}

if (isset($_POST['submit'])){
	include './source/class/class_core.php';
	
	$name = trim( $_POST['name'] );
	$pwd = trim( $_POST['pwd'] );
	
	$user_info = DB::result_first("SELECT id FROM `om_user` WHERE `name` = '$name' AND `pwd` = '$pwd'");
	if( $user_info ){
		$_SESSION['user_id'] = $user_info['id'];
		$_SESSION['name'] = $name;
		
		header('Location: index.php');
	} else {
		echo "<script>alert('提示：该用户不存在！');</script>";
	}
}


?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>登陆</title>
	<link rel="stylesheet" href="images/global.min.css">
</head>
<body id="login">
    <div id="header">
        欢迎加入木桶饭协会(YY群：6550976)，会长：MM不乖哦(YY号：909010484)，【本次系统升级丢失部分用户数据，如发现用户名不存在请重新注册】
    </div>
    <form method="post" id="form">
        <h1>木桶饭协会订餐系统</h1>
        <input type="text" name="name" class="name" />
        <input type="password" name="pwd" class="pwd" />
        <button type="submit" name="submit">登 陆</button>
        <a href="register.php" title="">新会员注册</a>
    </form>
<!-- 偷窥代码狂就是你，还看，就是你！ -->